package com.dingchw.singlemusic.controller;

import com.dingchw.singlemusic.dao.ArtistsDao;
import com.dingchw.singlemusic.define.annotation.UnWrapper;
import com.dingchw.singlemusic.define.exception.DataException;
import com.dingchw.singlemusic.model.dto.UserDTO;
import com.dingchw.singlemusic.model.entity.Artists;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

@RestController
@Api(tags = "API-测试")
public class TestController {
    @Autowired
    private ArtistsDao artistsDao;

    @GetMapping(value="/test")
    @ApiOperation(value="测试")
    public List<String> test(){
        return this.artistsDao.findAll().stream().map(Artists::getArtistename).collect(Collectors.toList());
    }

    @GetMapping(value="test01")
    @ApiOperation(value="测试1")
    public void tes01(){
        throw new DataException("hello");
    }

    @PostMapping(value="test02")
    @ApiOperation(value="测试2")
    public void tes01(@RequestBody List<UserDTO> list){
        throw new DataException("hello");
    }
}
